package thread.proxy;

public class LamdaFunction {
    //3.静态内部类
    static class Love2 implements Like {
        @Override
        public void lamda() {
            System.out.println("I like Lamda2！");
        }
    }

    public static void main(String[] args) {
        Like love = new Love1();
        love.lamda();

        love = new Love2();
        love.lamda();

        //4.局部内部类
        class Love3 implements Like {
            @Override
            public void lamda() {
                System.out.println("I like Lamda3！");
            }
        }
        love = new Love3();
        love.lamda();

        //5.匿名内部类
        //没有类的名称，必须借助接口或者父类
        love = new Like() {
            @Override
            public void lamda() {
                System.out.println("I like Lamda4！");
            }
        };
        love.lamda();

        //6.Lamda简化
        love = ()->{
            System.out.println("I like Lamda5！");
        };
        love.lamda();
    }
}

//1.定义函数式接口
interface Like {
    public void lamda();
}

//2.继承函数式接口实现类
class Love1 implements Like {
    @Override
    public void lamda() {
        System.out.println("I like Lamda1！");
    }
}